package isAnagram;

import java.util.Arrays;

public class Solution {
    public boolean isAnagram(String s, String t) {
        if(s.equals(t))return false;
        int[] cnt = new int[26];
        for (int i = 0; i < s.length(); i++) {
            cnt[s.charAt(i)-'a']++;
        }
        for (int i = 0; i < t.length(); i++) {
            if(cnt[t.charAt(i)-'a'] == 0) return false;
            cnt[t.charAt(i)-'a']--;
        }
        return Arrays.stream(cnt).sum() == 0;
    }
}
